<template>
  <!-- 导入弹窗 -->
  <el-dialog
    :visible.sync="importDialogVisible"
    custom-class="computerDialog"
    title="批量导入"
    width="600px"
  >
    <div style="width:400px;margin:0 auto">
      <el-steps :active="importStep" simple>
        <el-step title="导入数据" icon="el-icon-edit"></el-step>
        <el-step title="查看结果" icon="el-icon-upload"></el-step>
      </el-steps>
    </div>
    <template v-if="importStep == 0">
      <el-form label-width="200px" v-model="importForm">
        <el-form-item label="导入方式" key="importType" prop="importType">
          <el-radio v-model="importForm.importType" label="upload"
            >上传EXCEL
          </el-radio>

          <el-radio v-model="importForm.importType" label="clipboard"
            >粘贴文本</el-radio
          >
        </el-form-item>
        <div
          style="padding:5px 20px;"
          v-if="importForm.importType == 'clipboard'"
        >
          <el-alert
            title="文本格式"
            type="info"
            description="用户账号 （邮件地址）|计算机账号1，计算机账号2，计算机账号3;"
            show-icon
          >
          </el-alert>

          <el-input
            type="textarea"
            :rows="10"
            placeholder="zhangsan1|Computer-01,Computer-01,Computer-01
zhangsan2|Computer-03,Computer-04,Computer-05"
            v-model="importForm.clipboardText"
          >
          </el-input>
        </div>
      </el-form>
      <el-upload
        v-if="importForm.importType == 'upload'"
        style="text-align:center"
        class="upload-file"
        drag
        multiple
        :before-upload="beforeUpload"
        limit="1"
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
          只能上传xls/xlsx文件，且不超过10M
        </div>
        <div
          class="el-upload__tip"
          slot="tip"
          style="display: flex;justify-content: center;align-items: center;"
        >
          请按<el-link :href="templateUrl" type="primary">模板</el-link
          >填写数据后，上传Excel文件
        </div>
      </el-upload>

      <div style="text-align:center;margin-top:20px;">
        <el-button
          v-if="importForm.importType == 'upload'"
          type="primary"
          @click="submitUpload()"
          >开始导入</el-button
        >
        <el-button
          v-if="importForm.importType == 'clipboard'"
          type="primary"
          @click="confirmImport()"
          >开始导入</el-button
        >
      </div>
    </template>
    <div v-if="importStep == 1" style="padding-top: 10px;">
      <el-table
        :data="ImportStateList"
        size="mini"
        style="width: 100%"
        height="250"
      >
        <el-table-column label="账号" align="left" key="name" prop="name" />
        <el-table-column
          label="计算机"
          align="left"
          key="userWorkstations"
          prop="userWorkstations"
        />
        <el-table-column
          label="错误详情"
          align="left"
          key="errorMsg"
          prop="errorMsg"
        />
      </el-table>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "importDataDialog",
  data() {},
  props: {
    templateUrl: { type: String, default: "" },
    placeHolder: { type: String, default: "" }
  },
  methods: {}
};
</script>
<style scoped></style>
